<?php
/*
	首页
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$member=$this->model('member')->get_member();
	$member['credit1passtime']=date('Y年m月d日',time()+7*24*3600);
	$_SESSION['sex']=$member['sex'];
	$return['setting']=$return['pluginset'];
	$return['member']=$member;
	$return['params']=array('type'=>$_RQ['type']?:3);
	$return['list']=array();
	$return['pcd']=$this->session('pcd')?:array('city'=>'');
	$sharelink='jy_xiangqin/list//type='.$_RQ['type'].'&fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$return['pluginset']['share_title']?:'发现列表',
			'desc'=>$return['pluginset']['share_desc']?:'发现列表，成就天下姻缘！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>tomedia($return['pluginset']['share_image'])
	);
	set_html('title','动态列表');
	exi($return);
}
if($_RQ['op']=='uppcd'){
	$post=get_postdata();
	if($post['lat'] || $post['lng']){
		$lat_lng=array('lat'=>$post['lat'],'lng'=>$post['lng']);
		$this->session('lat_lng',$lat_lng);
	}
	$this->session('pcd',$post);
	exi('更新成功！');
}
if($_RQ['op']=='getmember'){
	$type=$_RQ['type'];
	//获取最近50家店
	if($_RQ['lat'] || $_RQ['lng']){
		$lat_lng=array('lat'=>$_RQ['lat'],'lng'=>$_RQ['lng']);
		$this->session('lat_lng',$lat_lng);
	}
	$lat_lng=$this->session('lat_lng');
	if($type==1){
		$order='juli';
	}elseif($type==2){
		$order='islike';
	}
	$params=array(
		'uniacid'=>$_SESSION['uniacid'],
		'status'=>0,
		'order'=>$order,
		'sex'=>$_SESSION['sex']==1?2:1,
	);
	if($_RQ['keyword']){
		$params['nickname like']='%'.trim($_RQ['keyword']).'%';
	}
	if($_RQ['city'] && $return['pluginset']['is_city']){
		$pcd=array(
			'province'=>$_RQ['province'],
			'city'=>$_RQ['city'],
			'district'=>$_RQ['district'],
		);
		$this->session('pcd',$pcd);
		$params['city']=$_RQ['city'];
	}
	$orderby='id desc';
	$pindex = max(1, 1);
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,10000),//获取所有
		'fields'=>'',
		'key'=>'id',
		'orderby'=>$orderby,
		'orderbykey'=>$orderbykey,
	);
	$logs=$this->model('member')->getmemberlist($parameter,$_RQ['limit'],$lat_lng,intval($_RQ['page']),intval($_RQ['juli']));
	foreach($logs as $k=>&$v){
		$v['logo']=$v['logo']?tomedia($v['logo']):'';
		$v['topimg']=$v['topimg']?tomedia($v['topimg']):'';
		$v['createtime']=date('Y-m-d',$v['createtime']);
		$v['pcd']=json_decode($v['pcd'],true);
	}
	$return['list']=array_values($logs);
	exi($return);
}
?>